"use strict";
angular.module('app', [ ]).controller('register',function($rootScope, $scope,$http, $location) {
	
	
	$scope.register = function() {
		$http.post('/register', {
			username:$scope.register.username,
			password: $scope.register.password
	    }, {
	        headers : {'X-CSRF-TOKEN' : $("#csrf_token").val()}
	    }).success(function(data){
	        if(data.resultFlag == 1) {
	        	 alert("注册成功!");
	        	 location.href="/login";
	        }else{	
	        	alert(data.reason);
	        }
	    }).error(function(){
	        alert("注册失败!");
	    });
		
	}
	

});
